package com.iims.flowable.mapper;

import com.iims.flowable.flow.domain.FlowBusinessConf;
import com.iims.flowable.flow.domain.FlowBusinessHistory;
import com.iims.flowable.flow.domain.FlowListenerHandle;
import com.iims.flowable.flow.domain.FlowTaskNodeConf;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 业务与流程配置Key
 *
 * @author fanpei
 * @date 2021/7/6 9:50
 */
@Mapper
public interface FlowBusinessConfMapper {
    /**
     * 通过handleKey获取一个配置
     *
     * @param handleKey
     * @return
     */
    FlowListenerHandle selectOneByHandleKey(@Param("handleKey") String handleKey);

    /**
     * 通过defKey获取一个任务节点配置
     *
     * @param defKey 流程定义Key
     * @return
     */
    FlowTaskNodeConf selectFlowTaskByHandleKey(@Param("defKey") String defKey, @Param("formKey") String formKey);

    /**
     * 获取流程业务key
     *
     * @param defKey
     * @return
     */
    FlowBusinessConf selectFlowBusinessConf(@Param("defKey") String defKey);

    /**
     * 若不存在则插入
     *
     * @param history
     * @return
     */
    int insertFlowBusinessHistoryNotExist(FlowBusinessHistory history);

    /**
     * 获取指定类型对象的业务key信息
     *
     * @param flowBusinessType
     * @param flowBusinessTargetId
     * @return
     */
    FlowBusinessHistory selectOneFlowBusinessHis(@Param("flowBusinessType") String flowBusinessType, @Param("flowBusinessTargetId") Long flowBusinessTargetId);

    /**
     * 获取指定业务的信息
     *
     * @param flowDefKey
     * @param flowBusinessKey
     * @return
     */
    FlowBusinessHistory selectOneFlowBusinessHisByflowDefBusinessKey(@Param("flowDefKey") String flowDefKey,@Param("flowBusinessKey") String flowBusinessKey);

}
